package com.example.smartclassroom.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.smartclassroom.entity.form.LoginForm;
import com.example.smartclassroom.entity.Teacher;
import com.example.smartclassroom.util.JsonDate;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

@Mapper
@Repository
public interface TeacherMapper extends BaseMapper<Teacher> {

    // 登录
    @Select("select * from teacher where username=#{username} and password=#{password}")
    Teacher login(LoginForm loginForm);

    // 注册
    @Insert("insert into teacher(username,password) values(#{username},#{password})")
    Integer insert(LoginForm loginForm);

    //编辑老师信息
    @Select("update teacher set teacher_name=#{teacherName},phone=#{phone},avatar=#{avatar} where id=#{id}")
    Integer update(Teacher teacher);
    //查询所有老师姓名
    @Select("select id,teacher_name from teacher")
    List<Teacher> queryAllTeacherName();
}
